package filter

import "github.com/sp-bridge/pkg/core"

type DefaultGatewayFilterChain struct {
	Index   int
	Filters []*GatewayFilter
}

func (f *DefaultGatewayFilterChain) Filter(exchange core.ServerWebExchange) {
	if f.Index < len(f.Filters) {
		filter := f.Filters[f.Index]
		chain := &DefaultGatewayFilterChain{
			Index: f.Index,
		}
		(*filter).Filter(exchange, chain)
	}
}
